package cn.iocoder.yudao.module.bpm.message.redis;

import cn.iocoder.yudao.framework.mq.redis.core.RedisMQTemplate;
import cn.iocoder.yudao.module.bpm.message.ProcessInstanceMessage;
import cn.iocoder.yudao.module.bpm.message.dto.*;
import cn.iocoder.yudao.module.bpm.message.redis.dto.*;
import lombok.extern.log4j.Log4j2;

@Log4j2
public class RedisProcessInstanceMessage implements ProcessInstanceMessage {

    private final RedisMQTemplate redisMQTemplate;

    public RedisProcessInstanceMessage(RedisMQTemplate redisMQTemplate) {
        this.redisMQTemplate = redisMQTemplate;
    }
    @Override
    public void onProcessInstanceCleanMsg(BpmProcessInstanceCancelledMessage bpmProcessInstanceCancelledMessage) {

        RedisBpmProcessInstanceCancelledMessage msg = new RedisBpmProcessInstanceCancelledMessage();
        msg.setBpmProcessMessage(bpmProcessInstanceCancelledMessage);
        redisMQTemplate.send(msg);
    }

    @Override
    public void onProcessInstanceFinishedMsg(BpmProcessInstanceApproveMessage bpmProcessInstanceApproveMessage) {
        RedisBpmProcessInstanceApproveMessage msg = new RedisBpmProcessInstanceApproveMessage();
        msg.setBpmProcessMessage(bpmProcessInstanceApproveMessage);
        redisMQTemplate.send(msg);
    }

    @Override
    public void onProcessInstanceRejectMsg(BpmProcessInstanceRejectMessage bpmProcessInstanceRejectMessage) {
        RedisBpmProcessInstanceRejectMessage msg = new RedisBpmProcessInstanceRejectMessage();
        msg.setBpmProcessMessage(bpmProcessInstanceRejectMessage);
        redisMQTemplate.send(msg);
    }

    @Override
    public void onProcessInstanceCreatedMsg(BpmProcessInstanceCreatedMessage bpmProcessInstanceCreatedMessage) {
        RedisBpmProcessInstanceCreatedMessage msg = new RedisBpmProcessInstanceCreatedMessage();
        msg.setBpmProcessMessage(bpmProcessInstanceCreatedMessage);
        redisMQTemplate.send(msg);
    }

    @Override
    public void onProcessInstanceStartedMsg(BpmProcessInstanceStartedMessage bpmProcessInstanceStartedMessage) {
        RedisBpmProcessInstanceStartedMessage msg = new RedisBpmProcessInstanceStartedMessage();
        msg.setBpmProcessMessage(bpmProcessInstanceStartedMessage);
        redisMQTemplate.send(msg);
    }
}
